<?php if (!empty($thread)) :?>
	<?php echo anchor('/', '<< Back'); ?>
	<h3><?php echo $thread->title; ?></h3>
	<?php echo $thread->content; ?>
	<?php if (!empty($tags)) : ?>
		<br>
		<span>Tags:</span>
		<?php foreach ($tags as $index => $row) : ?>
			<?php echo anchor('frontend/tag?tag='.$row->tag, $row->tag)?>
			<?php if ($index != count($tags)-1) : ?>
				<span>,</span>
			<?php endif; ?>
		<?php endforeach; ?>
	<?php endif; ?>
	<hr />
	<?php foreach($posts as $index => $post) : ?>
		<?php echo '#'.($index+1).'. '.$post->content; ?>
		<?php echo 'at '.$post->created_date;?>
		<?php echo anchor('frontend/deletePost/'.$post->id.'/'.$post->thread_id, 'Delete') ?>
		<hr>
	<?php endforeach; ?>
	
	<h3>Write a reply</h3>
	<?php if (!empty($errors)) :?>
	<?php foreach($errors as $error) :?>
		<span style="color:red;font-style="italic"></span>
	<?php endforeach; ?>
	<?php endif?>
	
	<form method="post" action="<?php echo site_url('frontend/reply'); ?>">
		<input type="hidden" name="thread_id" value="<?php echo $thread->id; ?>">
		<textarea name="content"></textarea>
		<input type="submit" value="Submit">
	</form>
<?php else:?>
	<h3>Page not found.</h3>
<?php endif; ?>
